<template>
	<view class="loading-container">
		<!-- 组织员管理 -->
		<loadingComponentsVue />
	</view>
</template>

<script>
	import loadingComponentsVue from '../../../components/loadingComponents.vue';
	import {
		removeUserTokenInfo
	} from '../../../utils/auth';
	export default {
		components: {
			loadingComponentsVue
		},
		data() {
			return {};
		},
		onShow() {
			removeUserTokenInfo()
			this.getUserInfo()
		},
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false;
			}
			uni.showModal({
				title: '提示',
				content: '是否退出当前页面？',
				success: function(res) {
					if (res.confirm) {
						this.$router.back();
						this.$router.back();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
			return true;
		},
		methods: {
			async getUserInfo() {
				try {
					const {
						platform
					} = uni.getSystemInfoSync();
					const isMobile = platform === 'ios' || platform === 'android';
					const credentials =
						'OrgMemberCredential&UnionCredential&PhoneNumberCredential';
					const res = await this.userTopAuth(isMobile, credentials);
					this.formDataSet(res);
				} catch (err) {
					console.log(err);
					this.$router.back();
				}
			},
			formDataSet(row) {
				if (row.UnionCredential || row.OrgMemberCredential ) {
					uni.redirectTo({
						url: '/pages/work/organizationalmanagement'
					});
				}

			},
		}
	}
</script>

<style scoped>

</style>